<template>
	<view>
		<u-navbar back-text="" title="修改昵称">
			<u-button @click="handleEdit" slot='right' size="mini" style="margin-right: 30rpx;">确定</u-button>
		</u-navbar>
		<view class="">
			<u-field label-width='0' v-model="name" label="" placeholder="请填写昵称" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: ''
			};
		},
		onLoad(e) {
			this.name = e.name || ''
		},
		methods: {
			async handleEdit() {
				await this.$u.api.updateNickName({
					nickName: this.name
				})
				uni.showToast({
					title: '修改成功',
					icon: 'success'
				})
				const userInfo = this.cache.getCache('busUserInfo')
				userInfo.nickName = this.name
				this.cache.setCache('busUserInfo', userInfo)
				uni.navigateTo({
					url: '/pages/userMsg/userMsg'
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
